package com.wry.controller;

import com.wry.dto.AccountDeductedDTO;
import com.wry.entity.TOrder;
import com.wry.rpc.AccountRpcService;
import com.wry.service.OrderApiService;
import com.wry.util.ApiResult;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.math.BigDecimal;

/**
 * <h1>  <h1>
 *
 * @author 魏如元
 * @since 2022/10/7
 */
@RestController
@RequestMapping("order")
public class OrderController {

    @Resource
    private OrderApiService orderApiService;

    @Resource
    private AccountRpcService accountRpcService;

    @PostMapping("create")
    public ApiResult<String> createOrder(@RequestBody TOrder tOrder){
        orderApiService.createOrder(tOrder);
        return ApiResult.SUCCESS("创建订单成功！");
    }

    @GetMapping("test")
    public ApiResult<String> test(){
        return accountRpcService.deductedAccount(new AccountDeductedDTO(1L,new BigDecimal(66)));
    }

}
